package com.taosdata.jdbc.springbootdemo.service;

import com.taosdata.jdbc.springbootdemo.dao.WeatherMapper;
import com.taosdata.jdbc.springbootdemo.dao.YakenMqttMapper;
import com.taosdata.jdbc.springbootdemo.domain.Weather;
import com.taosdata.jdbc.springbootdemo.domain.YakenMqtt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YakenMqttService {

    @Autowired
    private YakenMqttMapper yakenMqttMapper;

    public boolean init() {
        yakenMqttMapper.createDB();
        yakenMqttMapper.createTable();
        return true;
    }

//    public List<YakenMqtt> query(Long limit, Long offset) {
//        return yakenMqttMapper.select(limit, offset);
//    }

//    public int save(int temperature, float humidity) {
//        Weather weather = new Weather();
//        weather.setTemperature(temperature);
//        weather.setHumidity(humidity);
//
//        return weatherMapper.insert(weather);
//    }

    @Async
    public void save(List<YakenMqtt> weatherList) {
        yakenMqttMapper.batchInsert(weatherList);
    }

}
